class Solution:
    def minTimeToType(self, word: str) -> int:
        res = len(word)
        word = "a" + word
        for i in range(len(word) - 1):
            diff = abs(ord(word[i]) - ord(word[i + 1]))
            res += min(diff, 26 - diff)
        return res


if __name__ == "__main__":
    print(Solution().minTimeToType(word="abc"))  # 5
    print(Solution().minTimeToType(word="bza"))  # 7
    print(Solution().minTimeToType(word="zjpc"))  # 34
